import FightTimeUI from "./Fight/FightTimeUI";

@Component
export default class InteractorSample extends Script {
    protected async onStart(): Promise<void> {
        const interObj = this.gameObject as Interactor;

        // 开始交互回调
        interObj.onEnter.add(() => {
            console.log("onEnter");
            console.log("onEnter ", interObj.getCurrentCharacter());
            console.log("onEnter ", interObj.occupied);
        });

        // 结束交互回调
        interObj.onLeave.add(() => {
            console.log("onLeave");
        });

        // 设置交互插槽和动画ID
        interObj.slot = HumanoidSlotType.Buttocks;
        interObj.animationId = "4175";

        // 在客户端运行时绑定按键事件
        if (SystemUtil.isClient()) {
            // 当按下数字键 1 时执行进入交互
            InputUtil.onKeyDown(Keys.One, () => {
                interObj.enter(Player.localPlayer.character, HumanoidSlotType.Buttocks, "4175");

            });

            // 当按下数字键 2 时执行退出交互
            InputUtil.onKeyDown(Keys.Two, () => {
                interObj.leave();
            });
        }
    }
}